<%@ page import="pers.zdb.ag.AddressUtils" %>
<%@ page import="pers.zdb.ag.pojo.Address" %>
<%@ page import="pers.zdb.ag.util.IpUtils" %><%--
  Created by IntelliJ IDEA.
  User: paul
  Date: 2018/8/8
  Time: 14:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>经纬度(高德)的省市区信息</title>
  </head>

  <body>
  <%
    String apiUrl = "http://ijjk.ijjk.top/AddressGetter/address?location=113.575895,23.116969";
  %>
  api: <a target="_blank" href="<%=apiUrl %>"> <%=apiUrl %> </a>

  <%
  String result = "";
  String location = request.getParameter("location");

  if (location==null) location="";

  if (location!=null&&location.trim().length()>0){
      if(location.indexOf(",")==-1){
          result = "经纬度请用英文逗号隔开(如 113.575895,23.116969 )";
      }else{
         double longitude = Double.parseDouble(location.split(",")[0]);
         double latitude = Double.parseDouble(location.split(",")[1]);
         Address address = AddressUtils.getAddress(longitude,latitude);
        result = address.getProvince()+"-"+address.getCity()+"-"+address.getArea();
      }
  }else {
    result = "请输入经纬度(如 113.575895,23.116969 )";
  }
  %>
  <form  action="${pageContext.request.contextPath}" method="get">
  <table style="width:500px;margin-top: 15px;border:gray solid 1px;">
    <tr><td>维度,经度 ：</td> <td><input type="text" name="location" value="<%=location %>"></td> </tr>

    <tr><td>位置：</td> <td> <%=result %> </td> </tr>
    <tr><td rowspan="2"><input type="submit" value="提交"></td></tr>
  </table>

  <iframe src="https://lbs.amap.com/console/show/picker" style="width: 80%;height: 800px;margin-top:30px;"></iframe>
  </form>

  </body>

</html>
